<?php
/**
 * 
 * Customer Seach Result Grid
 * 
 */

use Fox\Common\Customer\Type;
use Fox\Html\AnchorObject;

$mode = isset($params['mode']) ? $params['mode'] : null;
$typeLabel = array();
$finder = new Type();
$types = $finder->find(new Fox\Dao\SqlFragment("language = ?",array(Xview::instance()->language())));
foreach($types as $type) {
	$typeLabel[$type->type] = $type->label();
}
$grid = new Fox\Grid("gResult");
$grid->fieldcat(array(array("customer_type","type"),"name1","uname","udate"));
$grid->fieldcat()->switchToObjectMode();
$grid->fieldcat()->setGenerators(array(
	'type' => Fox\Generator::useFunction(function ($data,$key) use($typeLabel){
		if(isset($typeLabel[$data->type]))
			return $typeLabel[$data->type];
		else 
			return $data->type;
	
	})));

	
$grid->setFieldAttr(array("name1"),"setAnchor",
								new AnchorObject("?mod=customer&act=update&mode=$mode",array(
					'customerid' => Fox\Generator::useAttribute())
				,"_blank"));
			
return $grid;